<template>
  <div>
    <el-table v-loading="loading" tooltip-effect="darkTable" :data="pcwRiskMonitorList" border :height="height">
      <el-table-column :label="$t('监控科目/指标')" align="center" prop="keyName" />
      <!-- <el-table-column :label="$t('上下行预警')" align="center" prop="warmUpdown" :formatter="riskTypeFormat" /> -->
      <el-table-column :label="$t('预警线')" align="center" prop="warnLine" width="80">
        <template slot-scope="scope">
          <span>{{ moneyFormat(scope.row.warnLine) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('警报线')" align="center" prop="alarmLine" width="80">
        <template slot-scope="scope">
          <span>{{ moneyFormat(scope.row.alarmLine) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('报警次数')" align="center" prop="riskType" width="150">
        <template slot-scope="scope">
          <span class="riskSpan">
            <span class="risk-type-red" />
            <i>
              {{ scope.row.alarmCount }}
            </i>
          </span>
          <span class="riskSpan">
            <span class="risk-type-yellow" />
            <i>{{ scope.row.warmCount }}</i>
          </span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
  import { listPcwRiskMonitor } from '@/api/company/pcw/pcwRiskMonitor'
  export default {
    name: 'PcwRiskMonitorInfo',
    props: {
      // 公司ID
      bussId: {
        type: String,
        required: true
      },
      height: {
        type: String,
        default: () => ''
      }
    },
    data() {
      return {
        // 遮罩层
        loading: true,
        // 总条数
        total: 0,
        // 指标监控表格数据
        pcwRiskMonitorList: [],
        // 查询参数
        queryParams: {
          companyId: this.bussId,
          newTitle: undefined,
          newSource: undefined,
          newTime: undefined,
          pageNum: 1,
          pageSize: 10
        },
        // 表单参数
        form: {}
      }
    },
    created() {
      this.getDicts('risk_monitor_type').then(response => {
        this.riskTypeOptions = response.data
      })
      this.getList()
    },
    methods: {
      riskTypeFormat(row) {
        return this.selectDictLabel(this.riskTypeOptions, row.warmUpdown)
      },
      getList() {
        this.loading = true
        this.queryParams.companyId = this.bussId
        listPcwRiskMonitor(this.queryParams).then(response => {
          this.pcwRiskMonitorList = response.rows
          this.loading = false
        })
      }
    }
  }
</script>
